﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QFramework;
using System;

namespace HareGame
{
    [MonoSingletonPath("GameEntry/EventManager")]
    public class EventManager : MonoBehaviour, ISingleton
    {
        /// <summary>
        /// 初始化
        /// </summary>
        public void OnSingletonInit()
        {

        }

        /// <summary>
        /// 定义单例
        /// </summary>
        public static EventManager Instance
        {
            get { return MonoSingletonProperty<EventManager>.Instance; }
        }

        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        /// <param name="onEvent">委托</param>
        /// <returns></returns>
        public IUnRegister Register(EventID eventID, Action<int, object[]> onEvent)
        {
            return EnumEventSystem.Global.Register(eventID, onEvent);
        }

        /// <summary>
        /// 注销事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        public void UnRegister(EventID eventID)
        {
            EnumEventSystem.Global.UnRegister(eventID);
        }

        /// <summary>
        /// 注销事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        /// <param name="onEvent">委托</param>
        public void UnRegister(EventID eventID, Action<int, object[]> onEvent)
        {
            EnumEventSystem.Global.UnRegister(eventID, onEvent);
        }

        /// <summary>
        /// 注销所有事件
        /// </summary>
        public void UnRegisterAll()
        {
            EnumEventSystem.Global.UnRegisterAll();
        }

        /// <summary>
        /// 发送事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        /// <param name="param">参数</param>
        public void Send(EventID eventID, params object[] param)
        {
            EnumEventSystem.Global.Send(eventID, param);
        }

        /// <summary>
        /// 发送事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        /// <param name="param">参数</param>
        public void Send(string eventID, params object[] param)
        {
            EnumEventSystem.Global.Send(eventID, param);
        }
    }
}
